<?php
namespace  app\admin\model;
use think\Model;
use think\facade\Request;
use \app\admin\validate\Nav as NavValidate;

class Nav extends Model{
    public function info($id){
        $map['id'] = $id;
        $info=Link::where($map)->find();
        return $info;
    }


    public function edit(){
        $data=Request::post();
        $validate = new NavValidate;
        if (!$validate->check($data)) {
            $this->error=$validate->getError();
            return false;
        }

        $Nav = new Nav();
        if(empty($data['id'])){
            $result = $Nav->allowField(true)->save($data);
        }else{
            $result = $Nav->allowField(true)->isUpdate(true)->save($data);
        }
        if(false === $result){
            return $Nav->getError();
            return false;
        }
        return $result;
    }
}